﻿@using SmartCode
@using SmartCode.Db
@model BuildContext
@{
    var project = Model.Project;
    var dbSource = Model.GetDataSource<DbSource>();
    var dbProvider = dbSource.DbProvider;
    var writeDataSource = dbSource.WriteDataSource;
}
<?xml version="1.0" encoding="utf-8" ?>
<!--
@{ await Html.RenderPartialAsync("Copyright.cshtml", Model); }
-->
<SmartSqlMapConfig xmlns="http://SmartSql.net/schemas/SmartSqlMapConfig.xsd">
    <Settings IsCacheEnabled="true" />
    <Properties>
        <Property Name="ConnectionString" Value="@writeDataSource.ConnectionString" />
        <Property Name="ScriptBuilder" Value="SmartSql.ScriptTag.ScriptBuilder,SmartSql.ScriptTag" />
        @if (dbSource.DbRepository.DbProvider == DbProvider.PostgreSql)
        {
            <Property Name="JsonTypeHandler" Value="SmartSql.TypeHandler.PostgreSql.JsonTypeHandler`1,SmartSql.TypeHandler.PostgreSql" />
        }
        else
        {
            <Property Name="JsonTypeHandler" Value="SmartSql.TypeHandler.JsonTypeHandler`1,SmartSql.TypeHandler" />
        }
    </Properties>
    <Database>
        <DbProvider Name="@dbProvider.Name" />
        <Write Name="@writeDataSource.Name" ConnectionString="${ConnectionString}" />
    </Database>
    <TagBuilders>
        <TagBuilder Name="Script" Type="${ScriptBuilder}" />
    </TagBuilders>
    <IdGenerators>
        <IdGenerator Name="SnowflakeId" Type="SnowflakeId">
            <Properties>
                <Property Name="WorkerIdBits" Value="5" />
                <Property Name="WorkerId" Value="1" />
                <Property Name="Sequence" Value="0" />
            </Properties>
        </IdGenerator>
    </IdGenerators>
    <SmartSqlMaps>
        <SmartSqlMap Path="Maps" Type="Directory"></SmartSqlMap>
    </SmartSqlMaps>
</SmartSqlMapConfig>
